<?php
namespace Game\Generator;

class ItemGenerator
{
    /**
     *
     * @var Game\Factory\CharacterFactory
     */
    protected $_item_factory;

    public function __construct()
    {
        $this->_item_factory = new \Game\Factory\CharacterFactory();
    }

    /**
     *
     * @return \Game\Factory\CharacterFactory
     */
    public function getItemFactory()
    {
        return $this->_item_factory;
    }

    /**
     *
     * @param \Game\Factory\CharacterFactory $item_factory
     */
    public function setItemFactory(\Game\Factory\CharacterFactory $item_factory)
    {
        $this->_item_factory = $item_factory;
    }

    /**
     *
     * @param array $params
     * @return Game\Entity\Item
     */
    public function generate($type, array $params)
    {
        $item = $this->getItemFactory()->create($type);

        $item->setTitle($params['title']);

        return $item;

    }
}